// index.js
import * as echarts from '../../assets/ec-canvas/echarts';
function initChart(canvas, width, height, dpr) {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height,
    devicePixelRatio: dpr // 适配高分屏
  });
  console.log(chart)
  canvas.setChart(chart);
  const option = {
    xAxis: {
      data: ['1', '2', '3', '4', '5', '6']
    },
    grid:{
      top:'13%',
      left:"8%",
      right:'8%',
      bottom:'8%'
    },
    legend:{
      show:true
    },
    yAxis: {},
    series: [
      {
        name: '负荷预测',
        smooth: true,
        areaStyle: {
          opacity: 0.2
        },
        type: 'line',
        data: [5, 20, 36, 10, 10, 20]
      },
      {
        name: '实时负荷',
        smooth: true,
        areaStyle: {
          opacity: 0.2
        },
        type: 'line',
        data: [15, 12, 16, 16, 18, 10]
      }
    ]
  };

  chart.setOption(option);
  return chart;
}

Page({
  data: {
    ec: {
      onInit: initChart,
     
    },
    },
    gocop(){
      wx.navigateTo({
        url: '/pages/cop/cop',
      })
    },

    goyunwei(){
      wx.navigateTo({
        url: '/pages/yunwei/yunwei',
      })
    },
  
    gopower(e){
     
      wx.setStorageSync('type', e.currentTarget.dataset.power)
      wx.navigateTo({
        url: '/pages/diandetail/diandetail?type='+e.currentTarget.dataset.power,
      })
    },
 
})
